//
// Created by ckxgz on 2021/6/4.
//
// 求集合A上所有不同的二元关系

#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;


vector<string> split(const string& str, const string& delim) {
    vector<string> res;
    if("" == str) return res;
    //先将要切割的字符串从string类型转换为char*类型
    char * strs = new char[str.length() + 1];
    strcpy(strs, str.c_str());

    char * d = new char[delim.length() + 1];
    strcpy(d, delim.c_str());

    char *p = strtok(strs, d);
    while(p) {
        string s = p; //分割得到的字符串转换为string类型
        res.push_back(s); //存入结果数组
        p = strtok(NULL, d);
    }

    return res;
}

set<string> input_set()
{
    string str;cin>>str;
    vector<string> v = split(str,"{,}");
    set<string> res(v.begin(),v.end());
    return res;
}

set<pair<string, string> > Cartesian_Product(set<string> s1, set<string> s2)
{
    set<pair<string, string> > res;
    for(auto i:s1) {
        for(auto j:s2) {
            res.insert(make_pair(i, j));
        }
    }
    return res;
}

void print_subset(vector<vector<pair<string,string> > > vec)
{   // 用以输出子集
    for (int i = 0; i < vec.size(); i++)
    {
        cout<<"{";
        for (int j = 0; j < vec[i].size(); j++)
        {
            if(j != vec[i].size() - 1) cout<< "<" <<vec[i][j].first<<","<<vec[i][j].second <<">"<<",";
            else cout<< "<" <<vec[i][j].first<<","<<vec[i][j].second <<">";
        }
        cout<<"}"<<endl;
    }
}

int main()
{
    set<string> s = input_set();
    set<pair<string, string> > s_t = Cartesian_Product(s,s);
    vector<pair<string, string> > s_p (s_t.begin(), s_t.end());
    reverse(s_p.begin(), s_p.end());

    for (int i = 0; i <= s_p.size(); ++i) {
        vector<int> choice(s_p.size(), 0);  // 选择数组, 初始化全为0
        for(int j = 0;j < i;++j)
        {   // 初始化待取元素个数的数组, 即该数组中共有i个1
            choice[choice.size() - 1 - j] = 1;
        }

        vector<vector<pair<string, string> > > subset;
        do {
            vector<pair<string, string> > p;
            for(int j = choice.size() - 1;j >= 0; --j) {
                if(choice[j] != 0) p.push_back(s_p[j]);
            }
            subset.push_back(p);
        } while (next_permutation(choice.begin(), choice.end()));
        sort(subset.begin(), subset.end());
        print_subset(subset);

    }
    return 0;
}
